﻿using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace AttachScreenShotToJira.CODE.CORE_LOGIC
{
    class MANAGE_PROCESSES
    {
        public static bool stopGreenshot()
        {
            try
            {
                // Get all processes running on the local computer.
                Process[] localByName = Process.GetProcessesByName("Greenshot");

                if (localByName.Length > 0)
                {
                    if (MessageBox.Show("Greenshot needs to be closed to complete this action. Once closed, please press OK.", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information) == DialogResult.OK)
                    {
                        return true;
                    }
                    else
                    {
                        return false;
                    }
                }
                else
                {
                    return true;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Unable to start/stop greenshot process. Reason: " + ex.ToString());
                return false;
            }
        }
    }
}
